﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<SinBiota.Model.Entities.Project>>" %>

<%@ Import Namespace="Localization" %>
<%@ Import Namespace="SinBiota.Model.Entities" %>
<%@ Import Namespace="Sinbiota.Web.Extensions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%: Strings.Project %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript" src="<%: Url.Content("~/Scripts/Custom/BiotaAjaxFunctions.js")%>"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%: Strings.Project %></h2>

<% using (Html.BeginForm())
    {%>
    <div style="margin-bottom:1em;">
    <div class="left">
    <%: Html.TextBox("Search", "", new { Class = "input-text" })%> 
    </div>
<%--   <div class="left" style="">
        <b><%: Strings.ProjectStatus %>:</b> 
    </div>
--%>
    <div class="left" style="margin-left:1em;">
    <%--<%: Html.EnumDropDownList<ProjectStatus>() %>--%>
        <select id="ProjectStatus" name="ProjectStatus">
            <option value="1"><%: Strings.Finished %></option>
            <option value="2"><%: Strings.InProgress %></option>
            <%--<option value="3"><%: Strings.Processing %></option>--%>
        </select>
    </div>
    <div class="left" style="margin-left:1em;">
    <input type="submit" class="button small" value="<%: Strings.Search %> "/>
    </div>
    <p class="clearfix">&nbsp;</p>
</div>
    <% }%>


    
    <table>
    <thead>
        <tr class="header">
             <th width="40">
            </th>
            <th>
                <%: Strings.Name %>
            </th>
            <th>
                <%: Strings.StartDate %>
            </th>
            <th>
                <%: Strings.EndDate%>
            </th>
            <th>
                <%: Strings.Occurrences %>
            </th>
        </tr>
    </thead>
        <% foreach (var item in Model)
           { %>
        <tr>
        <td>
            <% if (HttpContext.Current.User.IsInRole(Role.Admin.ToString()))
               { %>
                <% Html.RenderPartial("EditDetailsUserControl", item); %>
                <% }
               else
               { %>
               <%= Html.ImageActionLink(item.Id, "Details", Strings.Details, Url.Content("~/Content/img/details.png"))%>
                <% } %>
        </td>
            <td>
                <%= item.Name %>
            </td>
            <td>
                <%: item.StartDate %>
            </td>
            <td>
                <%: item.EndDate %>
            </td>
            <td>
                <%: Html.ActionLink(item.Occurrences.Count.ToString(), "Project", "Occurrence", new { id = item.Id }, null)%>
            </td>
        </tr>
        <% } %>
    </table>
    <p class="small button radius">
        <%: Html.ActionLink(Strings.CreateNew, "Create") %>
    </p>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#ProjectStatus").val(<%: ViewData["ProjectStatus"] %>);
            $("#ProjectStatus").height('26px');
            $("#ProjectStatus").width('150px');
        });
    </script>
</asp:Content>
